/*Cliente : Desde aca vamos a hacer todas las llamadas*/

#include "myFunctions.h"
#include "perceptron.h"
#include "sstream"

using namespace std;

int main(int argc,char *argv[]){
	vector<double> errores;	
	Perceptron P;
	
	genRandom("TrainingEj4.txt","TrainingEj4Random10.txt",10,5000);
	//genRandom("TrainingEj4.txt","TrainingEj4Random50.txt",50,5000);
	//genRandom("TrainingEj4.txt","TrainingEj4Random70.txt",70,5000);
	mdouble X;
	vector<int> Y;
	readFile(X,Y,"TrainingEj4Random10.txt",false);
	//readFile(X,Y,"TrainingEj4Random50.txt",false);
	//readFile(X,Y,"TrainingEj4Random70.txt",false);
	particionado(X,Y,0.8,10);
	for(int i=0; i<10; i++){
		mdouble X_training, X_test;
		vector<int> Y_training,Y_test;
		stringstream cvz;
		cvz<<i;
		string snumero=cvz.str();
		string nomArchi="Training/partTraining"+snumero+".txt";
		readFile(X_training,Y_training,nomArchi,true);
		P.training(X_training,Y_training,false);
		nomArchi="Test/partTest"+snumero+".txt";
		readFile(X_test,Y_test,nomArchi,true);
		errores.push_back(P.testWithFile(X_test,Y_test));
	}
	double sum = 0;
	for(unsigned int i=0;i<errores.size();i++){
		sum += errores[i];
	}
	sum = sum/errores.size();

	cout<<endl<<endl<<"El perceptron resuelve el problema con un "<<sum<<"% de aciertos"<<endl;
	return 0;
}
